/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package guiutilities;

import java.awt.image.BufferedImage;
import javax.swing.JButton;
import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JTextField;

/**
 *
 * @author tommy
 */
public class jImageSearchDialog extends JDialog {
	private boolean confirmed;
	private BufferedImage images[];
	private JTextField jImagePath1;
	private JTextField jImagePath2;
	private JButton jButtonBrowseImage1;
	private JButton jButtonBrowseImage2;
	private JButton jConfirmOperation;
	private JButton jCancelOperation;
	private JFileChooser jImageFileChooser;
	
	
//	public jImageSearchDialog(JFrame parent, ResourceMap resourceMap, JFileChooser jImageFileChooser) {
//		// Dialog for browsing and storing 2 images to perform operations among
//		// them
//		super(parent,"Select two images...", true);
//		
//		getContentPane().setLayout(new SpringLayout());
//		setPreferredSize(new Dimension(512,196));
//		setMaximumSize(new Dimension(512,196));
//		setResizable(false);
//		setSize(512, 196);
//		setDefaultCloseOperation(DISPOSE_ON_CLOSE);
//		images = new BufferedImage[2];
//		
//		jImagePath1 = new JTextField();
//		jImagePath1.setEditable(false);
//        jImagePath1.setText(resourceMap.getString("jImagePath1.text")); // NOI18N
//        jImagePath1.setMaximumSize(new java.awt.Dimension(350, 27));
//        jImagePath1.setName("jImagePath1"); // NOI18N
//        //jImagePath1.setPreferredSize(new java.awt.Dimension(350, 27));
//		jImagePath1.setMinimumSize(new Dimension(350, 27));
//		jImagePath1.setSize(500, 27);
//
//		
//		jImagePath2 = new JTextField();
//        jImagePath2.setEditable(false);
//        jImagePath2.setMaximumSize(new java.awt.Dimension(350, 27));
//        jImagePath2.setName("jImagePath2"); // NOI18N
//        jImagePath2.setPreferredSize(new java.awt.Dimension(350, 27));
//		jImagePath2.setSize(350, 27);
//		jImagePath2.setMinimumSize(new Dimension(350, 27));
//
//		jButtonBrowseImage1 = new JButton();
//        jButtonBrowseImage1.setText(resourceMap.getString("jButtonBrowseImage1.text")); // NOI18N
//        jButtonBrowseImage1.setName("jButtonBrowseImage1"); // NOI18N
//        jButtonBrowseImage1.addActionListener(new java.awt.event.ActionListener() {
//            public void actionPerformed(java.awt.event.ActionEvent evt) {
//                jButtonBrowseImage1ActionPerformed(evt);
//            }
//        });
//
//		jButtonBrowseImage2 = new JButton();
//        jButtonBrowseImage2.setText(resourceMap.getString("jButtonBrowseImage2.text")); // NOI18N
//        jButtonBrowseImage2.setName("jButtonBrowseImage2"); // NOI18N
//        jButtonBrowseImage2.addActionListener(new java.awt.event.ActionListener() {
//            public void actionPerformed(java.awt.event.ActionEvent evt) {
//                jButtonBrowseImage2ActionPerformed(evt);
//            }
//        });
//
//		jConfirmOperation = new JButton();
//        jConfirmOperation.setText(resourceMap.getString("jConfirmOperation.text")); // NOI18N
//        jConfirmOperation.setName("jConfirmOperation"); // NOI18N
//		jConfirmOperation.setPreferredSize(new Dimension(50,50));
//		jConfirmOperation.setMinimumSize(new Dimension(50,50));
//        jConfirmOperation.addActionListener(new java.awt.event.ActionListener() {
//            public void actionPerformed(java.awt.event.ActionEvent evt) {
//                jConfirmOperationActionPerformed(evt);
//            }
//        });
//
//		jCancelOperation = new JButton();
//        jCancelOperation.setText(resourceMap.getString("jCancelOperation.text")); // NOI18N
//        jCancelOperation.setName("jCancelOperation"); // NOI18N
//        jCancelOperation.addActionListener(new java.awt.event.ActionListener() {
//            public void actionPerformed(java.awt.event.ActionEvent evt) {
//                jCancelOperationActionPerformed(evt);
//            }
//        });
//		
//		this.jImageFileChooser  = jImageFileChooser;
//		
//		
//		getContentPane().add(jImagePath1);
//		
//		getContentPane().add(jButtonBrowseImage1);
//		
//		getContentPane().add(jImagePath2);
//		
//		getContentPane().add(jButtonBrowseImage2);
//		
//		getContentPane().add(jConfirmOperation);
//		
//		getContentPane().add(jCancelOperation);
//		
//		SpringUtilities.makeCompactGrid(getContentPane(), 3,2,6,6,6, 6);
//		
//	}
//	
//	public boolean isConfirmed() {
//		return this.confirmed;
//	}
//	
//	public BufferedImage getFirstImage() {
//		return this.images[0];
//	}
//	
//	public BufferedImage getSecondImage() {
//		return this.images[1];
//	}
//	
//	private void jConfirmOperationActionPerformed(java.awt.event.ActionEvent evt) {                                                     
//		if (this.images[0] != null && this.images[1] != null) {
//			this.confirmed = true;
//		} else {
//			this.confirmed = false;
//		}
//		this.dispose();
//	}
//	
//	private void jCancelOperationActionPerformed(java.awt.event.ActionEvent evt) {                                                    
//		this.images[0] = null;
//		this.images[1] = null;
//		this.confirmed = false;
//		this.dispose();
//	}
//	
//	private void jButtonBrowseImage1ActionPerformed(java.awt.event.ActionEvent evt) {                                                    
//		int chooseOption = jImageFileChooser.showOpenDialog(this);
//		BufferedImage bimg;
//		image.utils.ImageUtilities imgUtil = image.utils.ImageUtilitiesImpl.getInstance();
//		
//		if ((chooseOption == JFileChooser.APPROVE_OPTION)) {
//			try {
//				File imageFile = jImageFileChooser.getSelectedFile();
//				bimg = imgUtil.createImage(imgUtil.getBytesFromFile(imageFile), 256, 256, false);
//				jImagePath1.setText(imageFile.getAbsolutePath());
//				this.images[0] = bimg;
//			} catch (IOException ex) {
//				Logger.getLogger(ImageAnalyzerView.class.getName()).log(Level.SEVERE, null, ex);
//			}
//			
//		} else {
//			System.out.println("User Cancelled");
//		}
//	}
//	
//	private void jButtonBrowseImage2ActionPerformed(java.awt.event.ActionEvent evt) {                                                    
//		int chooseOption = jImageFileChooser.showOpenDialog(this);
//		BufferedImage bimg;
//		image.utils.ImageUtilities imgUtil = image.utils.ImageUtilitiesImpl.getInstance();
//		
//		if ((chooseOption == JFileChooser.APPROVE_OPTION)) {
//			try {
//				File imageFile = jImageFileChooser.getSelectedFile();
//				bimg = imgUtil.createImage(imgUtil.getBytesFromFile(imageFile), 256, 256, false);
//				jImagePath2.setText(imageFile.getAbsolutePath());
//				this.images[1] = bimg;
//			} catch (IOException ex) {
//				Logger.getLogger(ImageAnalyzerView.class.getName()).log(Level.SEVERE, null, ex);
//			}
//			
//		} else {
//			System.out.println("User Cancelled");
//		}
//	}
	
}
